package com.example.demo.controller.AuthorControl;

import com.example.demo.entity.BackResponseEntity;
import com.example.demo.entity.requestJson.BuyOnrChapterReq;
import com.example.demo.entity.requestJson.DeleteReq;
import com.example.demo.entity.requestJson.QuerybuyonrChapterReq;
import com.example.demo.entity.responseJson.BuyChaptersListRes;
import com.example.demo.entity.responseJson.QuerybuyonrChapterRes;
import com.example.demo.service.ChapterPurchaseService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : 洪俊新
 * @date : 2021/3/18 17:44
 * @description:
 */
@RestController
@RequestMapping("/author/chapterpurchase")
@Api(value = "章节购买接口", tags = "章节购买接口")
public class ChapterPurchaseController {
    @Autowired
    private ChapterPurchaseService chapterPurchaseService;

    @ApiOperation(value = "批量购买查询接口", notes = "传book_id")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/querychapterlist")
    public BackResponseEntity<List<BuyChaptersListRes>> querybuyChaptersListRes(DeleteReq deleteReq){
        return chapterPurchaseService.querybuyChaptersListRes(deleteReq);
    }

    @ApiOperation(value = "单章节购买查询接口", notes = "传book_id")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/queryonechapter")
    public BackResponseEntity<QuerybuyonrChapterRes> querybuyChaptersListRes(QuerybuyonrChapterReq querybuyonrChapterReq){
        return chapterPurchaseService.querybuyOneChaptersRes(querybuyonrChapterReq);
    }

    @ApiOperation(value = "单章节购买接口", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/buyonechapter")
    public BackResponseEntity<Object> buyOneChapter(BuyOnrChapterReq buyOnrChapterReq){
        return chapterPurchaseService.buyOneChapter(buyOnrChapterReq);
    }
}
